/*
	COMMON CLIENT SIDE JS
*/

function buildURL(){ // get the path of the database
	var loc = String(window.location.href) // current window location
	var path = loc.split('/'); // split the path with forward slash
	
	return path[2]; // return the 2nd bound of the path;
}

function removeDuplicates(inputArray) { //removes duplicate values of an array
    var i; // loop counter
    var len = inputArray.length; // get the length of an array
    var outputArray = []; // output of function
    var temp = {}; // temporary array to compare

    for (i = 0; i < len; i++) {
        temp[inputArray[i]] = 0; //initialize each element of the array
    }
    for (i in temp) {
        outputArray.push(i); // copy elements from input array to output array
    }
    return outputArray; // return the output array
}

function validateEmail($email) {
  var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  if( !emailReg.test( $email ) ) {
    return false;
  } else {
    return true;
  }
}